package com.kalaqia.push.jpush;

import android.content.Context;

import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import cn.jpush.android.api.JPushInterface;

import static com.kalaqia.push.jpush.TagAliasOperatorHelper.ACTION_SET;

/**
 * function:
 * project:XinYueGouAndroidShangJiaBan
 * describe:
 * created owner:kalaqia 421407393@qq.com
 * created date:2017/11/16 0016 10:01
 */
//<editor-fold desc="version update log">
// update owner:kalaqia  421407393@qq.com
// update datetime:2017/11/16 0016 10:01  
// update remark:
//</editor-fold>
public class JPushApp {

    private static int sequence = 1;

    public static void setTags(Context context, String token) {
        Set<String> tags = new LinkedHashSet<>();
        tags.add(token);
        TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
        tagAliasBean.action = ACTION_SET;
        sequence++;
        tagAliasBean.tags = tags;
        TagAliasOperatorHelper.getInstance().handleAction(context, sequence, tagAliasBean);
    }

    public static void init(Context context) {
        //        JPushInterface.setDebugMode(BuildConfig.LOG_DEBUG);    // 设置开启日志,发布时请关闭日志
        JPushInterface.init(context);            // 初始化 JPush
    }

    public static void cleanTag(Context context) {
        int i = (int) new Date().getTime();
        JPushInterface.cleanTags(context, i);
    }

}
